﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SqlServerDataTableToExcel
{
    public partial class frmFileSelect : Form
    {

        private Model.Item_Model objItem { get; set; }

        public frmFileSelect(Model.Item_Model _itemobj)
        {
            InitializeComponent();
            objItem = _itemobj;
            tbxfileName.Text = objItem.FileName;
        }

 

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(tbxfileName.Text))
                {
                    throw new Exception("请选择excel文件");
                }
                objItem.FileName = tbxfileName.Text;
                BLL.LocalDs.Update(objItem);

                BLL.FrmFuc exportFunc = new BLL.FrmFuc(objItem.Type);
                exportFunc.ImportExcel(objItem);
                MessageBox.Show("OK!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = "Excel文件|*.xls";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                tbxfileName.Text = saveFileDialog1.FileName;
            }
        }

        private void frmFileSelect_Load(object sender, EventArgs e)
        {

        }
    }
}
